package indi.dawn.superjumper.screens;

import indi.dawn.superjumper.Assets;
import indi.dawn.superjumper.SuperJumper;
import indi.dawn.superjumper.util.Constants;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;

public class WinScreen extends ScreenAdapter {
	SuperJumper game;
	OrthographicCamera cam;
	Animation bob,princess;
	String[] messages =Constants.messages;
	int currentMessage = 0;
	private float stateTime=0;
	
	public WinScreen(SuperJumper game) {
		this.game = game;
		cam = new OrthographicCamera(320,480);
		cam.position.set(320 / 2, 480 / 2, 0);
		cam.update();
//		princess = new TextureRegion(Assets.arrow.getTexture(), 210, 122, -40, 38);
		bob=Assets.bobIdel;
		princess=Assets.princess;
	}
	
	@Override
	public void render(float delta) {
		if(Gdx.input.justTouched()) {
			currentMessage++;
			if(currentMessage == messages.length) {
				currentMessage--;
				game.setScreen(new MainMenuScreen(game));
			}
		}
		stateTime+=delta;
		Gdx.gl.glClear(Constants.BUFFERBIT);
		game.batcher.setProjectionMatrix(cam.combined);
		game.batcher.begin();
		game.batcher.draw(Assets.backgroundRegion, 0, 0);
//		game.batcher.draw(Assets.castle, 60, 120, 200, 200);
		game.batcher.draw(Assets.castleAnim.getKeyFrame(stateTime, true), 60,120,200, 200);
//		game.batcher.draw(Assets.bobFall.getKeyFrame(0, true), 120, 200);
		game.batcher.draw(bob.getKeyFrame(stateTime, true), 120, 200);
		Assets.font.drawMultiLine(game.batcher, messages[currentMessage], 0, 400, 320, HAlignment.CENTER);
		game.batcher.draw(princess.getKeyFrame(stateTime, true),150, 200);
		game.batcher.end();
	}
}
